package util
{
	import mx.collections.ArrayList;
	
	import spark.components.DataGrid;

	public class OperateDataGrid extends  DataGrid
	{
		private var _editRole:String = "";
		private var _deleteRole:String = "";
		private var _isEditValid:Boolean = true;
		private var _isDeleteValid:Boolean = true;
		public function OperateDataGrid()
		{
			super();
		}
		override protected function childrenCreated():void
		{
			var mainPage:SHNOP = this.parentApplication as SHNOP;
			if(mainPage !=null)
			{
				if(_editRole!="")
				{
					_isEditValid = isContains(_editRole,mainPage.UserInfoItem[0][7]);
				}
				if(_deleteRole!="")
				{
					_isDeleteValid = isContains(_editRole,mainPage.UserInfoItem[0][7]);
				}
			}
		}
		
		public function isContains(sourceStr:String,targetStr:String):Boolean
		{
			if(sourceStr != null)
			{
				var roles:Array = sourceStr.split(",");
				for (var i:int=0; i<roles.length; i++)
				{
					if(roles[i] == targetStr)
					{
						return true;
						break;
					}
				}
			}
			return false;
		}
		public function set EditRole(value:String):void
		{
			_editRole = value;
		}
		
		public function set DeleteRole(value:String):void
		{
			_deleteRole = value;
		}
		
		public function get isEditValid():Boolean
		{
			return _isEditValid;
		}
		public function get isDeleteValid():Boolean
		{
			return _isDeleteValid;
		}
		
//		public function setScrollPos():void
//		{
//			
//			//if(columns == null || columns.length < 4)
//			//	return;
//			var xOffset:Number = 0;
//			//for(var i:int=0; i<1; ++i)
//				//xOffset += (columns as ArrayList).source[i].width;
//			if (scroller.horizontalScrollBar && scroller.horizontalScrollBar.x < 200){
//				scroller.horizontalScrollBar.x = 200;
//				
//				scroller.horizontalScrollBar.setActualSize(scroller.horizontalScrollBar.width - 200, 
//					scroller.horizontalScrollBar.height);
//			}
//			
//		}
//		
//		override protected function updateDisplayList(w:Number, h:Number):void
//		{
//			super.updateDisplayList(w, h);
//			setScrollPos();
//		}
	}
}